<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>InitPHP框架 PHP框架 - A PHP Framework - Validate验证数据API</title>
<link href="static/common.css" type="text/css" rel="stylesheet" />
<meta name="keywords" content="php框架，国产php框架, initphp框架，MVC，分层体系" />
<meta name="description" content="initphp框架是一款国产php框架。initphp框架主要基于MVC模式，具备代码清晰，操作简单，功能齐全，开发快速，高效安全等特点，是您选择php框架的首选。" />
</head>
<body>
<div class="header">
  <div class="header_nav">InitPHP (A PHP Framework) 用户手册</div>
  <div class="header_div">
    <div class="header_title">第6章 6.2.2 Validate验证数据</div>
    <div class="header_right"><a href="6_2_1.htm">上一页</a> <a href="6_2_3.htm">下一页</a> </div>
  </div>
</div>
<div class="title">目录</div>
<ul style="list-style:none;">
  <li><a href="#$this->controller->is_arr">$this->controller->is_arr</a></li>
  <li><a href="#$this->controller->is_card">$this->controller->is_card</a></li>
  <li><a href="#$this->controller->is_chinese">$this->controller->is_chinese</a></li>
  <li><a href="#$this->controller->is_email">$this->controller->is_email</a></li>
  <li><a href="#$this->controller->is_empty">$this->controller->is_empty</a></li>
  <li><a href="#$this->controller->is_english">$this->controller->is_english</a></li>
  <li><a href="#$this->controller->is_ip">$this->controller->is_ip</a></li>
  <li><a href="#$this->controller->is_length">$this->controller->is_length</a></li>
  <li><a href="#$this->controller->is_method">$this->controller->is_method</a></li>
  <li><a href="#$this->controller->is_mobile">$this->controller->is_mobile</a></li>
  <li><a href="#$this->controller->is_number">$this->controller->is_number</a></li>
  <li><a href="#$this->controller->is_phone">$this->controller->is_phone</a></li>
  <li><a href="#$this->controller->is_qq">$this->controller->is_qq</a></li>
  <li><a href="#$this->controller->is_require">$this->controller->is_require</a></li>
  <li><a href="#$this->controller->is_require">$this->controller->is_require</a></li>
  <li><a href="#$this->controller->is_safe_account">$this->controller->is_safe_account</a></li>
  <li><a href="#$this->controller->is_safe_nickname">$this->controller->is_safe_nickname</a></li>
  <li><a href="#$this->controller->is_safe_password">$this->controller->is_safe_password</a></li>
  <li><a href="#$this->controller->is_url">$this->controller->is_url</a></li>
  <li><a href="#$this->controller->is_zip">$this->controller->is_zip</a></li>
</ul>
<div class="nav"></div>

<div class="title">1. $this->controller->is_arr($value) 是否为数组，空数组返回FALSE<a name="$this->controller->is_arr"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>是否为数组，空数组返回FALSE。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">
public function run() {
	$value= array(1);
	if (!$this->controller->is_arr($value)) {
		exit('空数组');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">2. $this->controller->is_card($value) 检测是否是身份证号码<a name="$this->controller->is_card"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p> 检测是否是身份证号码。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">
public function run() {
	$value= '33';
	if (!$this->controller->is_card($value)) {
		exit('不是身份证');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">3. $this->controller->is_chinese($value) 检测是否中文<a name="$this->controller->is_chinese"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>  检测是否中文。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">
public function run() {
	$value= 311100;
	if (!$this->controller->is_chinese($value)) {
		exit('不是中文');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">4. $this->controller->is_email($value) 是否是邮箱地址<a name="$this->controller->is_email"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>是否是邮箱地址。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">
public function run() {
	$value= '420332292qq.com';
	if (!$this->controller->is_email($value)) {
		exit('邮箱地址');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">5. $this->controller->is_empty($value) 不能为空<a name="$this->controller->is_empty"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>不能为空。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">
public function run() {
	$value= 'asdas';
	if ($this->controller->is_empty($value)) {
		exit('不能为空');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">6. $this->controller->is_english($value) 是否是英语<a name="$this->controller->is_english"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>  是否是英语。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">
public function run() {
	$value= 311100;
	if (!$this->controller->is_english($value)) {
		exit('不是英文字母');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">7. $this->controller->is_ip($value) 检测是否是正确的IP<a name="$this->controller->is_ip"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>检测是否是正确的IP。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">
public function run() {
	$value= '420332292qq.com';
	if (!$this->controller->is_ip($value)) {
		exit('非IP');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">8. $this->controller->is_length($value, $min = 0, $max= 0) 检测字符串长度<a name="$this->controller->is_length"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p> 检测字符串长度。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
 <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
	    <tr>
      <td>$min</td>
      <td>Int</td>
      <td>否</td>
      <td>字符串最小长度</td>
    </tr>
	    <tr>
      <td>$max</td>
      <td>Int</td>
      <td>否</td>
      <td>字符串最大长度</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">
public function run() {
	$value= 'asdsad';
	if (!$this->controller->is_length($value, 0, 2)) {
		exit('字符串长度不正确');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">9. $this->controller->is_method($object, $method) 检测对象中的方法是否存在<a name="$this->controller->is_method"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p> 检测对象中的方法是否存在。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$object</td>
      <td>Obj </td>
      <td>是</td>
      <td>对象名称</td>
    </tr>
	    <tr>
      <td>$method</td>
      <td>String </td>
      <td>是</td>
      <td>方法名称</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$this->controller->is_method($object, $method);
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">10. $this->controller->is_mobile($value) 检测是否是电话号码<a name="$this->controller->is_mobile"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>检测是否是电话号码。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 86356037;
	if (!$this->controller->is_mobile($value)) {
		exit('不是电话');
	} 
	$this->view->display(); //模板显示 
}
</pre>
<div class="nav"></div>

<div class="title">11. $this->controller->is_number($value) 检测是否是数字<a name="$this->controller->is_number"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p> 检测是否是数字。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 'asdas';
	if (!$this->controller->is_number($value)) {
		exit('不是数字');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">12. $this->controller->is_phone($value) 是否是手机号码<a name="$this->controller->is_phone"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p> 是否是手机号码。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 86356037;
	if (!$this->controller->is_phone($value)) {
		exit('不是电话');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">13. $this->controller->is_qq($value) 检测是否是QQ<a name="$this->controller->is_qq"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p> 检测是否是QQ。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 311100;
	if (!$this->controller->is_qq($value)) {
		exit('不是QQ');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">14. $this->controller->is_require($value) 是否需要必填的字符串<a name="$this->controller->is_require"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>是否需要必填的字符串。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= '';
	if (!$this->controller->is_require($value)) {
		exit('必填的数据');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">15. $this->controller->is_safe_account($value) 检测是否是安全的账号<a name="$this->controller->is_safe_account"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p> 检测是否是安全的账号。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 311100;
	if (!$this->controller->is_safe_account($value)) {
		exit('不是安全的账号');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">16. $this->controller->is_safe_nickname($value) 检测是否是安全的账号<a name="$this->controller->is_safe_nickname"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p> 检测是否是安全的nickname。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 311100;
	if (!$this->controller->is_safe_nickname($value)) {
		exit('不是安全的账号');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">17. $this->controller->is_url($value) 检测是否是URL<a name="$this->controller->is_url"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>  检测是否是URL。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 'http://www.initphp.com';
	if (!$this->controller->is_url($value)) {
		exit('不是电话');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>

<div class="title">18. $this->controller->is_zip($value) 检测是否是邮政编码<a name="$this->controller->is_zip"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>检测是否是邮政编码。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 311100;
	if (!$this->controller->is_zip($value)) {
		exit('不是邮政编码');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>



<div class="title">19. $this->controller->is_safe_password 检测是否是安全的密码<a name="$this->controller->is_safe_password"></a></div>
<div class="title">
  <h3>接口描述：</h3>
</div>
<p>  检测是否是安全的密码。在Controller中使用</p>
<div class="title">
  <h3>参数：</h3>
</div>
<table>
    <tr>
      <th style="width:20%;"> 参数 </th>
      <th style="width:20%;"> 类型 </th>
      <th style="width:10%;"> 是否必须 </th>
      <th style="width:50%;"> 描述 </th>
    </tr>
    <tr>
      <td>$value</td>
      <td>String </td>
      <td>是</td>
      <td>需要验证的值</td>
    </tr>
</table>
<div class="title">
  <h3>使用：</h3>
</div>
<pre id="PHP" class="prettyprint">	
public function run() {
	$value= 311100;
	if (!$this->controller->is_safe_password($value)) {
		exit('是否是安全的密码');
	} 
	$this->view->display(); //模板显示
}
</pre>
<div class="nav"></div>


<div class="footer">版权所有：<a href="">http://initphp.com</a> InitPHP (A PHP Framework) By @Aliyun_zhuli</div>
<script src="static/jquery.js" type="text/javascript"></script>
<link href="static/prettify/prettify.css" rel="stylesheet" type="text/css">
<script src="static/prettify/prettify.js" type="text/javascript"></script>
<script type="text/javascript" src="static/comm.js"></script>
</body>
</html>
